<!-- 
=============COPYRIGHT============ 
Tin Book - An I-Read-This prototype for Tin Can API
Copyright (C) 2012  Andrew Downes

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
<http://www.gnu.org/licenses/>.
	
=============CREDITS============ 
Thanks to Rustici Software for provision of TCDriver.js which powers
the calls to the Tin Can API and for developing the Tin Can API 
TCDriver.js is reproduced here by permission under the understanding that 
it is still a prototype. It comes from the prototype package found at:
http://scorm.com/project-tin-can-phase-3-prototyping-tin-can-content-outside-of-the-lms/

=============DEVELOPMENT STATUS============
This software is currently in development and is NOT intended to be used
in a live situation. 

-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta charset="utf-8" />
		<title>I Defined This Verb</title>
		<style>
		/*TODO: Make the input boxes look nicer & tidy up css!!!*/
			body { 
			 background: #d5d4d1; 
			 text-align: center;
			 
			 font-family: Georgia, Serif;
			}
			div
			{
				text-align: left;
				background: #fff; 
				margin:1em auto;
				width:700px;
				padding:1em;
			}
			input
			{
				width:350px;

			}
			label
			{
				width: 200px;

			}
			.Element span
			{
				width:600px;
			}
			.title
			{
				font-size:larger;
				font-weight:bold;
				display:block;
				
			}
			h1{color: #FF4545;}
			
			#submitVerb
			{
				clear:both;
			
				font-size: 16pt;
				font-weight: bold;
				color: #FF4545;
				text-align: center;
				cursor:pointer;
			}

			.YouQualified
			{
				color: #FF4545;
				font-size:larger;
				font-weight:bold;
				display:block;
				margin:0px 10px;
			}
			
		</style>
		<!-- swfobject -->
		<script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
		
		<!-- jquery (Not currently used, but included because I'm sure it will be...) -->
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
		
		<!-- Rustici's Tin Can functions - call these to access the Tin can API-->
		<script src="http://tin-can-can.googlecode.com/files/TCDriver.js"></script>
		
		<!-- Base64 -->
		<script src="http://tin-can-can.googlecode.com/files/base64.js"></script>
		
		<!-- TinCanCan - main js file for this wrapper -->
		<script src="Tinverbs.js"></script>
		<!-- <script src="http://tin-can-can.googlecode.com/files/Tinverbs.js"></script>-->
		
		
		
		<script>		

		//fill the verb selectors with the lsit of default verbs
		
		
		$(function(){
		
			
			$('#submitVerb').click(function(){
				//TODO: sanitise the input		

				var verbId = "http://www.example.com/verb/" + $('#verbId').val(),
				verbDefinitionObj = {"id" : verbId}
				verbDefinitionObj['displayName'] = $('#verbDisplayName').val();
				verbDefinitionObj['summary'] = $('#verbSummary').val();
				
				var verbAliasOf = $('#verbAlias-of').val();
				if (!((verbAliasOf == "")||(verbAliasOf === undefined)))
				{
					TCDriver_Log('alias found');
					verbDefinitionObj['alias-of'] = verbAliasOf;
				}
				
				var verbSpecializationOf= $('#verbSpecialization-of').val();
				if (!((verbSpecializationOf == "")||(verbSpecializationOf === undefined)))
				{
					verbDefinitionObj['specialization-of'] = verbSpecializationOf;
					verbDefinitionObj['tense'] = $('#verbTense').val();
					verbDefinitionObj['voice'] = $('#verbVoice').val();
					verbDefinitionObj['negation'] = $('#verbNegation').val();
				}
				
				var stmt = 
				{ 
					"verb": "imported",
					"object":{
						"id":verbId,
						"definition": verbDefinitionObj,
						"objectType" : "verb"
					}
					
				};
				
				TCDriver_Log(stmt);
				console.log(tc_lrs.actor);
				TCDriver_SendStatement(tc_lrs, stmt, function() {
					var Element = $('<div></div>'); 
					Element.append (JSON.stringify(stmt));
					Element.addClass('Element');			
					$('body').html(Element);
					$('body').append ($('<span class="instructions">Statement reported to LRS. Refresh this page to start again!</span>'));
					$('body').append ($('<p><a href="http://beta.projecttincan.com/ClientPrototypes/StatementViewer/" target="_blank">Click here to see the results</a></p>'));
				});
				
			});

		
		
		});
		
				  
		
		</script>
	</head>
	<body >
	<noscript>
		This tool requires JavaScript to be enabled in your browser. Please enable JavaScript, then relaunch the course.
	</noscript>
	
	<h1>Verb Importer</h1>
	<div>
	<p>This tool shows how verbs could be imported to an LRS. It sends the statement to Rustici's LRS, which will probably generate an error because it doesn't yet support verb imports!</p>
	</div>
	
	<div>
	<label for="verbId">VerbId suffix (use name of verb):</label> <input type="text" name="verbId" id="verbId" /> <br/>
	<label for="verbDisplayName">Display name:</label> <input type="text" name="verbDisplayName" id="verbDisplayName" /><br/>
	<label for="verbSummary">Summary:</label> <input type="text" name="verbSummary" id="verbSummary"  /><br/>
	<label for="verbAlias-of">Alias-of (leave blank for none):</label> <input type="text" name="verbAlias" id="verbAlias"  /><br/>
	<label for="verbSpecialization-of">Specialization-of (leave blank for none):</label> <input type="text" name="verbSpecialization-of" id="verbSpecialization-of"  /><br/>
	<label for="verbTense">Tense:</label> <select name="verbTense" id="verbTense" >
	  <option value="past">Past</option>
	  <option value="present">Present</option>
	  <option value="future">Future</option>
	</select>
	<label for="verbVoice">Voice:</label> <select name="verbVoice" id="verbVoice" >
	  <option value="active">Active</option>
	  <option value="passive">Passive</option>
	</select>
	<label for="verbNegation">Negation:</label> <select name="verbNegation" id="verbNegation" >
	  <option value="positive">Positive</option>
	  <option value="negative">Negative</option>
	</select>
	<input name="submitVerb" id="submitVerb" type="button" value="Submit verb." />
	</div>
		
		
		
		

	</body>
</html>
